
const { regeneratorRuntime } = global

Page(global.connect(
  state => ({
    ...state.globalReducer,
    ...state.activityReducer
  }),
  dispatch => ({
    // todo 打电话失败的原型
    handleStoreClick(e) {
      console.log('handleStoreClick', e)
      const { detail } = e.currentTarget.dataset
      if(detail && detail.mobile) {
        const phoneNumber = detail.mobile
        wx.makePhoneCall({
          phoneNumber,
          success(e){

          },
          fail(e){
            console.error(e)
            if(e.errMsg !== 'makePhoneCall:fail cancel') {
              console.error(e)
            }
          },
        })
      }
    },
    async handleGetAuditStoreList(e) {
      console.log('handleSubmit')
      const actionRes = await dispatch(global.activityReducer.getAuditStoreList({
        id: this.data.minaLoginRes.data.user_id,
      }))
      console.log(actionRes)
      if (actionRes.actionStatus !== 'SUCCESS') {
        this.selectComponent('#toast').handleShow({
          message: actionRes.apiMes
        })
      }
    },
  })
)({
  data: {
    user: {

    },
    // todo api确认 需求状态确认
    stores: {
      list: [
        { id: 0, storeName: '欧洲城店1', storeMan: '李大头1', mobile: '15000000000' },
        { id: 1, storeName: '欧洲城店2', storeMan: '李大头2', mobile: '15000000000' },
        { id: 2, storeName: '欧洲城店3', storeMan: '李大头3', mobile: '15000000000' },
        { id: 3, storeName: '欧洲城店4', storeMan: '李大头4', mobile: '15000000000' },
        { id: 4, storeName: '欧洲城店5', storeMan: '李大头5', mobile: '15000000000' },
        { id: 5, storeName: '欧洲城店6', storeMan: '李大头6', mobile: '15000000000' },
        { id: 6, storeName: '欧洲城店7', storeMan: '李大头7', mobile: '15000000000' },
        { id: 7, storeName: '欧洲城店8', storeMan: '李大头8', mobile: '15000000000' },
        { id: 8, storeName: '欧洲城店9', storeMan: '李大头9', mobile: '15000000000' },
        { id: 9, storeName: '欧洲城店', storeMan: '李大头', mobile: '15000000000' },
        { id: 10, storeName: '欧洲城店', storeMan: '李大头', mobile: '15000000000' },
        { id: 11, storeName: '欧洲城店', storeMan: '李大头', mobile: '15000000000' },
        { id: 12, storeName: '欧洲城店', storeMan: '李大头', mobile: '15000000000' },
        { id: 13, storeName: '欧洲城店', storeMan: '李大头', mobile: '15000000000' },
        { id: 14, storeName: '欧洲城店', storeMan: '李大头', mobile: '15000000000' },
        { id: 15, storeName: '欧洲城店', storeMan: '李大头', mobile: '15000000000' },
        { id: 16, storeName: '欧洲城店', storeMan: '李大头', mobile: '15000000000' },
      ],
      mes: '',
      actionStatus: 'SUCCESS'
    }
  },
  onLoad() {
    console.log('page store onLoad')
    console.log('create-activity onLoad')
    this.handleGetAuditStoreList()
  },
  handleBack(){
    wx.navigateBack()
  },
  handleStoreItemTap(e) {
    console.log('handleStoreItemTap', e)
    const {detail} = e.currentTarget.dataset
    const user = {
      uiUserType: '店长',
      name: detail.manager_name,
      mobile: detail.mobile,
    }
    this.setData({ user })
    this.selectComponent('#pop').handleShow()
  },
  handleMakeCall(e){
    console.log('handleMakeCall', e)
    const { detail } = e
    if(detail && detail.mobile) {
      const phoneNumber = detail.mobile
      wx.makePhoneCall({
        phoneNumber,
        success(e){

        },
        fail(e){
          console.error(e)
          if(e.errMsg !== 'makePhoneCall:fail cancel') {
            console.error(e)
          }
        },
      })
    }
  }
}))